import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;

import java.io.FileOutputStream;
import java.io.IOException;

public class GeneratePDF {

	public static void main(String[] args) throws IOException, DocumentException {

		Document doc = new Document();
		PdfWriter.getInstance(doc, new FileOutputStream("JavaGeneratedPDF.pdf"));
		doc.open();
		

	    PdfPTable cardsTable = new PdfPTable(4);
	    cardsTable.setWidthPercentage(80);
	    cardsTable.getDefaultCell().setFixedHeight(140);


	    BaseFont mainFont = BaseFont.createFont("cardc.ttf", BaseFont.IDENTITY_H, true);
	    Font black = new Font(mainFont, 21f, 0, BaseColor.BLACK);
	    Font red = new Font(mainFont, 21f, 0, BaseColor.RED);
	    
	    String rank = "";
	    char suit = ' ';
	    
	    for (int suits = 1; suits <= 4; suits++)
        {
            for (int ranks = 1; ranks <= 13; ranks++)
            {
                switch (ranks)
                {
                    case 1: rank = "A"; break;
                    case 2: rank = "K"; break;
                    case 3: rank = "Q"; break;
                    case 4: rank = "J"; break;
                    case 5: rank = "10"; break;
                    case 6: rank = "9"; break;
                    case 7: rank = "8"; break;
                    case 8: rank = "7"; break;
                    case 9: rank = "6"; break;
                    case 10: rank = "5"; break;
                    case 11: rank = "4"; break;
                    case 12: rank = "3"; break;
                    case 13: rank = "2"; break;
                }

                switch (suits)
                {
                    case 1: suit = '♣'; cardsTable.addCell(new Paragraph(rank + suit + " ", black)); break;
                    case 2: suit = '♦'; cardsTable.addCell(new Paragraph(rank + suit + " ", red)); break;
                    case 3: suit = '♥'; cardsTable.addCell(new Paragraph(rank + suit + " ", red)); break;
                    case 4: suit = '♠'; cardsTable.addCell(new Paragraph(rank + suit + " ", black)); break;
                }
            }
        }
	    
	    doc.add(cardsTable);
	    doc.close();
	}
}
